// 实现注册效果
function checkun(){
    var reg = /^.{6,10}$/
    var usernameVul = document.getElementById("username").value
    var usertip = document.querySelector(".userTip")
    if(reg.test(usernameVul)){
        localStorage.setItem("username",usernameVul)
        usertip.style.display="none"
        return true
    }else{
        usertip.style.display="block"
        return false
    }
}
function checkpass(){
    var reg = /^[a-zA-Z][0-9]{6,10}$/
    var pawVul = document.getElementById("paw").value
    var pawtip = document.querySelector(".pawTip")
    if(reg.test(pawVul)){
        localStorage.setItem("password",pawVul)
        pawtip.style.display="none"
        return true
    }else{
        pawtip.style.display="block"
        return false
    }
}
function checkrepaw(){
    var pawVul = document.getElementById("paw").value
    var repawVul = document.getElementById("repaw").value
    var repawtip = document.querySelector(".repawTip")
    
    if(pawVul==repawVul){
        repawtip.style.display="none"
        return true
    }else{
        repawtip.style.display="block"
        return false
    }
}
function sub(){
    if(checkun() && checkpass() && checkrepaw()){
        alert("注册成功")
    }
}
function denglu(){
    var usernameVul = document.getElementById("userName").value
    var pawVul = document.getElementById("Paw").value
    var username = localStorage.getItem("username")
    var paw = localStorage.getItem("password")
    if(username==usernameVul && paw==pawVul){
        return true

    }else{
        alert("用户名或密码不正确")
        return false
    }
}
var games = document.querySelectorAll("#game")
var yuLan = document.getElementById("yulan")
var type = document.querySelectorAll("#type")
var typeArr
var typeT = document.querySelectorAll("#typeText")
var gameName = document.querySelectorAll("#GameName")
var yGameName = document.getElementById("yGameName")
var yImg = document.querySelectorAll("#yImg")
var imgArr = [
    "images/y1.png",
    "images/y2.png",
    "images/y3.png",
    "images/y4.png"
]
var imgArr1 = [
    "images/g2-1.png",
    "images/g2-2.png",
    "images/g2-3.png",
    "images/g2-4.png"
]
games.forEach((item,inD)=>{
    item.addEventListener("mouseenter",function(){
        games.forEach((i,indexOf)=>{
            i.style.marginRight= "20px"
            typeT.forEach((item,index)=>{
                typeArr=type[indexOf].innerHTML.split("&nbsp")
                typeT.innerHTML=typeArr[index]
            })
        })
        item.style.marginRight= "0px"
        yGameName.innerHTML= gameName[inD].innerHTML
        typeT[0].innerHTML=type[inD].innerHTML.split("&nbsp")[0]
        typeT[1].innerHTML=type[inD].innerHTML.split("&nbsp")[1]
        typeT[2].innerHTML=type[inD].innerHTML.split("&nbsp")[2]
        if(inD==1){
            yImg.forEach((item,index)=>{
                item.src=imgArr1[index]
            })
        }else{
            yImg.forEach((item,index)=>{
                item.src=imgArr[index]
            })
        }
    })
})
// 登录注册切换
const sigiInBtn = document.querySelector("#signIn")
const sigiUpBtn = document.querySelector("#signUp")
const container = document.querySelector(".container")
sigiInBtn.addEventListener("click",()=>{
    container.classList.remove("panel-active")
})
sigiUpBtn.addEventListener("click",()=>{
    container.classList.add("panel-active")
})
